{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An Introduction to py-Goldsberry\n",
    "===\n",
    "\n",
    "`py-Goldsberry` is a Python package that makes it easy to interface with the http://stats.nba.com and retrieve the data in a more analyzable format. \n",
    "\n",
    "This is the first in a series of tutorials that walk through the different modules of the packages and how to use each to get different types of data. \n",
    "\n",
    "If you've made it this far, you're probably less interested in reading about the package and more interested in actually using it.\n",
    "\n",
    "## Installation\n",
    "\n",
    "If you don't have the package installed, use `pip` install get the latest version \n",
    "\n",
    "    pip install py-goldsberry\n",
    "    pip install --upgrade py-goldsberry\n",
    "\n",
    "When you have `py-goldsberry` installed, you can load the package and check the version number"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1.0.1'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import goldsberry\n",
    "import pandas as pd\n",
    "goldsberry.__version__"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`py-goldsberry` is designed to work in conjuntion with Pandas. Each function within the package returns data in a format that is easily converted to a Pandas DataFrame.\n",
    "\n",
    "To get started, let's get a list of all of the players who were on an NBA roster during the 2015-16 season\n",
    "\n",
    "### PlayerIDs\n",
    "\n",
    "Currently, the `PlayerList()` function defaults to the current season. We start by creating an object, `players`, that we will use to scrape player data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DISPLAY_FIRST_LAST</th>\n",
       "      <th>DISPLAY_LAST_COMMA_FIRST</th>\n",
       "      <th>FROM_YEAR</th>\n",
       "      <th>GAMES_PLAYED_FLAG</th>\n",
       "      <th>PERSON_ID</th>\n",
       "      <th>PLAYERCODE</th>\n",
       "      <th>ROSTERSTATUS</th>\n",
       "      <th>TEAM_ABBREVIATION</th>\n",
       "      <th>TEAM_CITY</th>\n",
       "      <th>TEAM_CODE</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>TEAM_NAME</th>\n",
       "      <th>TO_YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Quincy Acy</td>\n",
       "      <td>Acy, Quincy</td>\n",
       "      <td>2012</td>\n",
       "      <td>Y</td>\n",
       "      <td>203112</td>\n",
       "      <td>quincy_acy</td>\n",
       "      <td>1</td>\n",
       "      <td>SAC</td>\n",
       "      <td>Sacramento</td>\n",
       "      <td>kings</td>\n",
       "      <td>1610612758</td>\n",
       "      <td>Kings</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Jordan Adams</td>\n",
       "      <td>Adams, Jordan</td>\n",
       "      <td>2014</td>\n",
       "      <td>Y</td>\n",
       "      <td>203919</td>\n",
       "      <td>jordan_adams</td>\n",
       "      <td>1</td>\n",
       "      <td>MEM</td>\n",
       "      <td>Memphis</td>\n",
       "      <td>grizzlies</td>\n",
       "      <td>1610612763</td>\n",
       "      <td>Grizzlies</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Steven Adams</td>\n",
       "      <td>Adams, Steven</td>\n",
       "      <td>2013</td>\n",
       "      <td>Y</td>\n",
       "      <td>203500</td>\n",
       "      <td>steven_adams</td>\n",
       "      <td>1</td>\n",
       "      <td>OKC</td>\n",
       "      <td>Oklahoma City</td>\n",
       "      <td>thunder</td>\n",
       "      <td>1610612760</td>\n",
       "      <td>Thunder</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Arron Afflalo</td>\n",
       "      <td>Afflalo, Arron</td>\n",
       "      <td>2007</td>\n",
       "      <td>Y</td>\n",
       "      <td>201167</td>\n",
       "      <td>arron_afflalo</td>\n",
       "      <td>1</td>\n",
       "      <td>NYK</td>\n",
       "      <td>New York</td>\n",
       "      <td>knicks</td>\n",
       "      <td>1610612752</td>\n",
       "      <td>Knicks</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Alexis Ajinca</td>\n",
       "      <td>Ajinca, Alexis</td>\n",
       "      <td>2008</td>\n",
       "      <td>Y</td>\n",
       "      <td>201582</td>\n",
       "      <td>alexis_ajinca</td>\n",
       "      <td>1</td>\n",
       "      <td>NOP</td>\n",
       "      <td>New Orleans</td>\n",
       "      <td>pelicans</td>\n",
       "      <td>1610612740</td>\n",
       "      <td>Pelicans</td>\n",
       "      <td>2015</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  DISPLAY_FIRST_LAST DISPLAY_LAST_COMMA_FIRST FROM_YEAR GAMES_PLAYED_FLAG  \\\n",
       "0         Quincy Acy              Acy, Quincy      2012                 Y   \n",
       "1       Jordan Adams            Adams, Jordan      2014                 Y   \n",
       "2       Steven Adams            Adams, Steven      2013                 Y   \n",
       "3      Arron Afflalo           Afflalo, Arron      2007                 Y   \n",
       "4      Alexis Ajinca           Ajinca, Alexis      2008                 Y   \n",
       "\n",
       "   PERSON_ID     PLAYERCODE  ROSTERSTATUS TEAM_ABBREVIATION      TEAM_CITY  \\\n",
       "0     203112     quincy_acy             1               SAC     Sacramento   \n",
       "1     203919   jordan_adams             1               MEM        Memphis   \n",
       "2     203500   steven_adams             1               OKC  Oklahoma City   \n",
       "3     201167  arron_afflalo             1               NYK       New York   \n",
       "4     201582  alexis_ajinca             1               NOP    New Orleans   \n",
       "\n",
       "   TEAM_CODE     TEAM_ID  TEAM_NAME TO_YEAR  \n",
       "0      kings  1610612758      Kings    2015  \n",
       "1  grizzlies  1610612763  Grizzlies    2015  \n",
       "2    thunder  1610612760    Thunder    2015  \n",
       "3     knicks  1610612752     Knicks    2015  \n",
       "4   pelicans  1610612740   Pelicans    2015  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "players = goldsberry.PlayerList()\n",
    "players2015 = pd.DataFrame(players.players())\n",
    "players2015.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can manipulate the `players` object to get data from different seasons by changing the API parameters and then re-running the query of the website. For example, if we want to get a list of players who were on an NBA roster during the 1990-91 season, we set the `Season` parameter to `1990-91` using the `.get_new_data()` method of the `players` class as follows."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "players.get_new_data(Season = '1990-91')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once we get the raw data from the website, we need to save it as a dataframe to a new object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DISPLAY_FIRST_LAST</th>\n",
       "      <th>DISPLAY_LAST_COMMA_FIRST</th>\n",
       "      <th>FROM_YEAR</th>\n",
       "      <th>GAMES_PLAYED_FLAG</th>\n",
       "      <th>PERSON_ID</th>\n",
       "      <th>PLAYERCODE</th>\n",
       "      <th>ROSTERSTATUS</th>\n",
       "      <th>TEAM_ABBREVIATION</th>\n",
       "      <th>TEAM_CITY</th>\n",
       "      <th>TEAM_CODE</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>TEAM_NAME</th>\n",
       "      <th>TO_YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Mark Alarie</td>\n",
       "      <td>Alarie, Mark</td>\n",
       "      <td>1986</td>\n",
       "      <td>Y</td>\n",
       "      <td>76019</td>\n",
       "      <td>HISTADD_mark_alarie</td>\n",
       "      <td>1</td>\n",
       "      <td>WAS</td>\n",
       "      <td>Washington</td>\n",
       "      <td>wizards</td>\n",
       "      <td>1610612764</td>\n",
       "      <td>Bullets</td>\n",
       "      <td>1990</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Steve Alford</td>\n",
       "      <td>Alford, Steve</td>\n",
       "      <td>1987</td>\n",
       "      <td>Y</td>\n",
       "      <td>76024</td>\n",
       "      <td>HISTADD_steve_alford</td>\n",
       "      <td>1</td>\n",
       "      <td>DAL</td>\n",
       "      <td>Dallas</td>\n",
       "      <td>mavericks</td>\n",
       "      <td>1610612742</td>\n",
       "      <td>Mavericks</td>\n",
       "      <td>1990</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Cedric Ball</td>\n",
       "      <td>Ball, Cedric</td>\n",
       "      <td>1990</td>\n",
       "      <td>Y</td>\n",
       "      <td>76090</td>\n",
       "      <td>HISTADD_cedric_ball</td>\n",
       "      <td>1</td>\n",
       "      <td>LAC</td>\n",
       "      <td>Los Angeles</td>\n",
       "      <td>clippers</td>\n",
       "      <td>1610612746</td>\n",
       "      <td>Clippers</td>\n",
       "      <td>1990</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ken Bannister</td>\n",
       "      <td>Bannister, Ken</td>\n",
       "      <td>1984</td>\n",
       "      <td>Y</td>\n",
       "      <td>76094</td>\n",
       "      <td>HISTADD_ken_bannister</td>\n",
       "      <td>1</td>\n",
       "      <td>LAC</td>\n",
       "      <td>Los Angeles</td>\n",
       "      <td>clippers</td>\n",
       "      <td>1610612746</td>\n",
       "      <td>Clippers</td>\n",
       "      <td>1990</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Greg Butler</td>\n",
       "      <td>Butler, Greg</td>\n",
       "      <td>1988</td>\n",
       "      <td>Y</td>\n",
       "      <td>76320</td>\n",
       "      <td>HISTADD_gregory_butler</td>\n",
       "      <td>1</td>\n",
       "      <td>LAC</td>\n",
       "      <td>Los Angeles</td>\n",
       "      <td>clippers</td>\n",
       "      <td>1610612746</td>\n",
       "      <td>Clippers</td>\n",
       "      <td>1990</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  DISPLAY_FIRST_LAST DISPLAY_LAST_COMMA_FIRST FROM_YEAR GAMES_PLAYED_FLAG  \\\n",
       "0        Mark Alarie             Alarie, Mark      1986                 Y   \n",
       "1       Steve Alford            Alford, Steve      1987                 Y   \n",
       "2        Cedric Ball             Ball, Cedric      1990                 Y   \n",
       "3      Ken Bannister           Bannister, Ken      1984                 Y   \n",
       "4        Greg Butler             Butler, Greg      1988                 Y   \n",
       "\n",
       "   PERSON_ID              PLAYERCODE  ROSTERSTATUS TEAM_ABBREVIATION  \\\n",
       "0      76019     HISTADD_mark_alarie             1               WAS   \n",
       "1      76024    HISTADD_steve_alford             1               DAL   \n",
       "2      76090     HISTADD_cedric_ball             1               LAC   \n",
       "3      76094   HISTADD_ken_bannister             1               LAC   \n",
       "4      76320  HISTADD_gregory_butler             1               LAC   \n",
       "\n",
       "     TEAM_CITY  TEAM_CODE     TEAM_ID  TEAM_NAME TO_YEAR  \n",
       "0   Washington    wizards  1610612764    Bullets    1990  \n",
       "1       Dallas  mavericks  1610612742  Mavericks    1990  \n",
       "2  Los Angeles   clippers  1610612746   Clippers    1990  \n",
       "3  Los Angeles   clippers  1610612746   Clippers    1990  \n",
       "4  Los Angeles   clippers  1610612746   Clippers    1990  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "players1990 = pd.DataFrame(players.players())\n",
    "players1990.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Each class in `py-Goldsberry` works in a similar fashion. When instantiating each class, the class makes some assumptions about the parameters to use to query the NBA website and executes the query. If you want to change the query after instantiation, you can change the query parameters and then re-query the database with `.get_new_data()`. Under the hood, the `.get_new_data()` method takes any number of keyword arguments that it then translates to api parameters. As a sanity check, it will raise an exception if you try to set a parameter that the specific query does not take.\n",
    "\n",
    "Each class takes a specific set of parameters. `py-Goldsberry` is built to include a list of each parameter as well as a default value. I'm working on a dictionary of parameters and possible values each can take. Look for it to be posted in the near future. Until then, you can access the raw parameter dictionary by calling the `.get_parameter_items()` method of each class. This gives you the possible values that the query can take. \n",
    "\n",
    "As you saw above, you can pass in keyword arguments with the keyword being the parameter name and the argument being the desired value to change the default value of the paramters. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'IsOnlyCurrentSeason': '1', 'LeagueID': '00', 'Season': '1990-91'}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "players.get_parameter_items()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the case of the `PlayersList()` class, you can get a historical list of players by changing the value of `'IsOnlyCurrentSeason'` from 1 to 0."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DISPLAY_FIRST_LAST</th>\n",
       "      <th>DISPLAY_LAST_COMMA_FIRST</th>\n",
       "      <th>FROM_YEAR</th>\n",
       "      <th>GAMES_PLAYED_FLAG</th>\n",
       "      <th>PERSON_ID</th>\n",
       "      <th>PLAYERCODE</th>\n",
       "      <th>ROSTERSTATUS</th>\n",
       "      <th>TEAM_ABBREVIATION</th>\n",
       "      <th>TEAM_CITY</th>\n",
       "      <th>TEAM_CODE</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>TEAM_NAME</th>\n",
       "      <th>TO_YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Alaa Abdelnaby</td>\n",
       "      <td>Abdelnaby, Alaa</td>\n",
       "      <td>1990</td>\n",
       "      <td>Y</td>\n",
       "      <td>76001</td>\n",
       "      <td>HISTADD_alaa_abdelnaby</td>\n",
       "      <td>1</td>\n",
       "      <td>POR</td>\n",
       "      <td>Portland</td>\n",
       "      <td>blazers</td>\n",
       "      <td>1610612757</td>\n",
       "      <td>Trail Blazers</td>\n",
       "      <td>1994</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Zaid Abdul-Aziz</td>\n",
       "      <td>Abdul-Aziz, Zaid</td>\n",
       "      <td>1968</td>\n",
       "      <td>Y</td>\n",
       "      <td>76002</td>\n",
       "      <td>HISTADD_zaid_abdul-aziz</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td>1977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Kareem Abdul-Jabbar</td>\n",
       "      <td>Abdul-Jabbar, Kareem</td>\n",
       "      <td>1969</td>\n",
       "      <td>Y</td>\n",
       "      <td>76003</td>\n",
       "      <td>HISTADD_kareem_abdul-jabbar</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td>1988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Mahmoud Abdul-Rauf</td>\n",
       "      <td>Abdul-Rauf, Mahmoud</td>\n",
       "      <td>1990</td>\n",
       "      <td>Y</td>\n",
       "      <td>51</td>\n",
       "      <td>HISTADD_mahmoud_abdul-rauf</td>\n",
       "      <td>1</td>\n",
       "      <td>DEN</td>\n",
       "      <td>Denver</td>\n",
       "      <td>nuggets</td>\n",
       "      <td>1610612743</td>\n",
       "      <td>Nuggets</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Tariq Abdul-Wahad</td>\n",
       "      <td>Abdul-Wahad, Tariq</td>\n",
       "      <td>1997</td>\n",
       "      <td>Y</td>\n",
       "      <td>1505</td>\n",
       "      <td>tariq_abdul-wahad</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td>2003</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    DISPLAY_FIRST_LAST DISPLAY_LAST_COMMA_FIRST FROM_YEAR GAMES_PLAYED_FLAG  \\\n",
       "0       Alaa Abdelnaby          Abdelnaby, Alaa      1990                 Y   \n",
       "1      Zaid Abdul-Aziz         Abdul-Aziz, Zaid      1968                 Y   \n",
       "2  Kareem Abdul-Jabbar     Abdul-Jabbar, Kareem      1969                 Y   \n",
       "3   Mahmoud Abdul-Rauf      Abdul-Rauf, Mahmoud      1990                 Y   \n",
       "4    Tariq Abdul-Wahad       Abdul-Wahad, Tariq      1997                 Y   \n",
       "\n",
       "   PERSON_ID                   PLAYERCODE  ROSTERSTATUS TEAM_ABBREVIATION  \\\n",
       "0      76001       HISTADD_alaa_abdelnaby             1               POR   \n",
       "1      76002      HISTADD_zaid_abdul-aziz             0                     \n",
       "2      76003  HISTADD_kareem_abdul-jabbar             0                     \n",
       "3         51   HISTADD_mahmoud_abdul-rauf             1               DEN   \n",
       "4       1505            tariq_abdul-wahad             0                     \n",
       "\n",
       "  TEAM_CITY TEAM_CODE     TEAM_ID      TEAM_NAME TO_YEAR  \n",
       "0  Portland   blazers  1610612757  Trail Blazers    1994  \n",
       "1                               0                   1977  \n",
       "2                               0                   1988  \n",
       "3    Denver   nuggets  1610612743        Nuggets    2000  \n",
       "4                               0                   2003  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "players.get_new_data(IsOnlyCurrentSeason = 0)\n",
    "playersAllTime = pd.DataFrame(players.players())\n",
    "playersAllTime.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "By default, Goldsberry is set to pull data from the current year. If you are interested in alternative data from the get-go, you can set the default parameters do your desired values upon insantiation of the class. Let's checkout an example of getting the All-Time player list from a brand new object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DISPLAY_FIRST_LAST</th>\n",
       "      <th>DISPLAY_LAST_COMMA_FIRST</th>\n",
       "      <th>FROM_YEAR</th>\n",
       "      <th>GAMES_PLAYED_FLAG</th>\n",
       "      <th>PERSON_ID</th>\n",
       "      <th>PLAYERCODE</th>\n",
       "      <th>ROSTERSTATUS</th>\n",
       "      <th>TEAM_ABBREVIATION</th>\n",
       "      <th>TEAM_CITY</th>\n",
       "      <th>TEAM_CODE</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>TEAM_NAME</th>\n",
       "      <th>TO_YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Alaa Abdelnaby</td>\n",
       "      <td>Abdelnaby, Alaa</td>\n",
       "      <td>1990</td>\n",
       "      <td>Y</td>\n",
       "      <td>76001</td>\n",
       "      <td>HISTADD_alaa_abdelnaby</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td>1994</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Zaid Abdul-Aziz</td>\n",
       "      <td>Abdul-Aziz, Zaid</td>\n",
       "      <td>1968</td>\n",
       "      <td>Y</td>\n",
       "      <td>76002</td>\n",
       "      <td>HISTADD_zaid_abdul-aziz</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td>1977</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Kareem Abdul-Jabbar</td>\n",
       "      <td>Abdul-Jabbar, Kareem</td>\n",
       "      <td>1969</td>\n",
       "      <td>Y</td>\n",
       "      <td>76003</td>\n",
       "      <td>HISTADD_kareem_abdul-jabbar</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td>1988</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Mahmoud Abdul-Rauf</td>\n",
       "      <td>Abdul-Rauf, Mahmoud</td>\n",
       "      <td>1990</td>\n",
       "      <td>Y</td>\n",
       "      <td>51</td>\n",
       "      <td>HISTADD_mahmoud_abdul-rauf</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Tariq Abdul-Wahad</td>\n",
       "      <td>Abdul-Wahad, Tariq</td>\n",
       "      <td>1997</td>\n",
       "      <td>Y</td>\n",
       "      <td>1505</td>\n",
       "      <td>tariq_abdul-wahad</td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td></td>\n",
       "      <td>0</td>\n",
       "      <td></td>\n",
       "      <td>2003</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    DISPLAY_FIRST_LAST DISPLAY_LAST_COMMA_FIRST FROM_YEAR GAMES_PLAYED_FLAG  \\\n",
       "0       Alaa Abdelnaby          Abdelnaby, Alaa      1990                 Y   \n",
       "1      Zaid Abdul-Aziz         Abdul-Aziz, Zaid      1968                 Y   \n",
       "2  Kareem Abdul-Jabbar     Abdul-Jabbar, Kareem      1969                 Y   \n",
       "3   Mahmoud Abdul-Rauf      Abdul-Rauf, Mahmoud      1990                 Y   \n",
       "4    Tariq Abdul-Wahad       Abdul-Wahad, Tariq      1997                 Y   \n",
       "\n",
       "   PERSON_ID                   PLAYERCODE  ROSTERSTATUS TEAM_ABBREVIATION  \\\n",
       "0      76001       HISTADD_alaa_abdelnaby             0                     \n",
       "1      76002      HISTADD_zaid_abdul-aziz             0                     \n",
       "2      76003  HISTADD_kareem_abdul-jabbar             0                     \n",
       "3         51   HISTADD_mahmoud_abdul-rauf             0                     \n",
       "4       1505            tariq_abdul-wahad             0                     \n",
       "\n",
       "  TEAM_CITY TEAM_CODE  TEAM_ID TEAM_NAME TO_YEAR  \n",
       "0                            0              1994  \n",
       "1                            0              1977  \n",
       "2                            0              1988  \n",
       "3                            0              2000  \n",
       "4                            0              2003  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_playersAllTime = pd.DataFrame(goldsberry.PlayerList(IsOnlyCurrentSeason=0).players())\n",
    "new_playersAllTime.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "playersAllTime.equals(new_playersAllTime)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Well, it looks like these data frames aren't quite identical. Why is that?\n",
    "\n",
    "Take a look at the `ROSTERSTATUS` column. When we first asked for the all time players, remember we had set the base year to 1990-91? Alaa Abdelnaby was actually on a roster during that season (Portland to be specific) so he has a value of `1` in the `ROSTERSTATUS` column. Since he was not in the league during the current season, he has a `0` in that column for the second pull. Let's compare just the names and see if we get an exact match. That will further reinforce that we have the same data, but we are looking at it from diffent points in time."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "playersAllTime.loc[:, 'DISPLAY_FIRST_LAST'].equals(new_playersAllTime.loc[:, 'DISPLAY_FIRST_LAST'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Success!\n",
    "\n",
    "This notebook outlines the general work flow for working with `py-Goldsberry`. I'll post additional workbooks outline additional data pulls and illustrating some of the other features of the package and possibilities with the data."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
